/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mvp.levelup.lists;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author WORKSPOT2
 */
public class ArrayListMain
{

    public static void main(String[] args)
    {
        ArrayList<String> arrList = new ArrayList<String>();
        arrList.add("String1");
        arrList.add("String2");
        arrList.add("String3");
        arrList.add("String4");
        arrList.add("String5");
        arrList.add(4, "String0");

        Iterator<String> iter = arrList.iterator();
        String tmp;
        int i = 0;
        while (iter.hasNext() && i < 4)
        {
            tmp = iter.next();
            if (i == 3)
            {
                iter.remove();
            }
            i++;
        }
        arrList.trimToSize();

        iter = arrList.iterator();
        while (iter.hasNext())
        {
            tmp = iter.next();
            System.out.println(tmp);
        }

        for (String tmp1 : arrList)
        {
            
            System.out.println(tmp1);
        }
        
        Employee e1 = new Employee(1, "Vasya", 30);
        Employee e2 = new Employee(1, "Petya", 40);
        Employee e3 = new Employee(1, "Dasha", 35);
        
        List<Employee> all = new ArrayList<Employee>();
        all.add(e1);
        all.add(e2);
        all.add(e3);
        
        Collections.sort(all);
        
        Iterator<Employee> iterEmpl = all.iterator();
        Employee tmpEmpl;
        while(iterEmpl.hasNext()){
            tmpEmpl = iterEmpl.next();
            System.out.println(tmpEmpl.getName() + " - " + tmpEmpl.getSalary());
        }

    }
}
